package portal.mybatis.page;

import java.io.Serializable;
import java.util.List;

public  class Page<T> implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 4718015062429226787L;
	long pageSize=10;
	long pageCount=0;
//	long page=1;
	long total=0;
	long start=0;
	private String searchText;
	String orders;
	String sort;
	String sortOrder;
	T sear;
	List<T> rows=null;
	public Page(){};
	public Page(long pageSize,long offset){
		this.pageSize=pageSize;
		this.start=offset;
	}
	public Page(long pageSize,long offset,String sort,String order){
		this(pageSize,offset);
		this.sort=sort;
		this.sortOrder=order;
		
	}
	public Page(long pageSize,long offset,String searchText){
		this(pageSize,offset);
		this.searchText=searchText;
		
	}
	public Page(long pageSize,long offset,String searchText,String sort,String order){
		this(pageSize,offset,searchText);
		this.sort=sort;
		this.sortOrder=order;
	}
	public long getPageSize() {
		return pageSize;
	}
	public long getPageCount() {
		if(total>=0)
			pageCount=(total-1)/pageSize+1;
		return pageCount;
	}
//	public long getPage() {
//		return page;
//	}
	public Object getRows() {
		return rows;
	}
	public void setPageSize(long pageSize) {
		this.pageSize = pageSize;
	}
	public void setPageCount(long pageCount) {
		this.pageCount = pageCount;
	}
//	public void setPage(long pageNow) {
//		this.page = pageNow;
//	}
	public void setRows(List<T> data) {
		this.rows = data;
	}
	public String getSearchText() {
		if(searchText==null || searchText.length()==0)
			return null;
		return "%"+searchText+"%";
	}
	public void setSearchText(String searchText) {
		this.searchText = searchText;
	}
	public long getTotal() {
		return total;
	}
	public void setTotal(long total) {
		this.total = total;
	}	
	public long getStart(){
		return start;
	}
	public String getOrders() {
		return orders;
	}
	public String getSort() {
		return sort;
	}
	public String getSortOrder() {
		return sortOrder;
	}
	public void setOrders(String orders) {
		this.orders = orders;
	}
	public void setSort(String sort) {
		this.sort = sort;
	}
	public void setSortOrder(String sortOrder) {
		this.sortOrder = sortOrder;
	}
	public T getSear() {
		return sear;
	}
	public void setSear(T sear) {
		this.sear = sear;
	}	
}
